<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul id="main">
        <li></li>
    </ul>
    <script>
        /**
         * 判断一个节点是否为后代
         * 1、contains()
         * 2、compareDocumentPosition()
        */

        const main = document.getElementById('main')
        const li = main.children[0]
        const res = main.contains(li)
        console.log(res)  // true

        const res1 = main.compareDocumentPosition(li)
        console.log(res1) // 20  为后代

    </script>
</body>
</html>